{% extends 'djangobb_forum/base.html' %}
{% load forum_extras %}
{% load i18n %}

{% block extra_meta %}
<script type="text/javascript" src="{{ STATIC_URL }}djangobb_forum/js/jquery.cookie.js"></script>
<script type="text/javascript">

	function set_collapser(cat_id) {
		category_body_id = "category_body_" + cat_id;
		if($.cookie(category_body_id)){
			item_id = "#" + category_body_id;
			head_id = item_id.replace("body", "head");
			$(head_id).addClass("collapsed");
			$(item_id).hide()
		}
	}
	$(document).ready(function(){
		$("a.toggle").click(function(){
			header_id = $(this).parent().attr('id');
			body_id = header_id.replace("head", "body");
			item_id = '#' + body_id
			if ($(this).parent().attr('class')==''){
				$(this).parent().addClass("collapsed");
				$.cookie(body_id, 'collapsed');
			}else {
				$(this).parent().removeClass("collapsed");
				$.cookie(body_id, '');
			}
			$(item_id).slideToggle("slow");
		});
	{% for iter in cats %}
		set_collapser({{ iter.id }})
	{% endfor %}
	});
</script>
{% endblock %}

{% block content %}
<div id="idx1" class="blocktable">
{% for iter in cats %}
	<h2 id="category_head_{{ iter.id }}">
		<a class="toggle" href="#">Toggle shoutbox</a>
		<span>
			{{ iter.cat }}
		</span>
	</h2>
	<div class="box" id="category_body_{{ iter.id }}">
		<div class="inbox">
			<table cellspacing="0">
				<thead>
					<tr>
						<th class="tcl" scope="col">{% trans "Forum" %}</th>
						<th class="tc2" scope="col">{% trans "Topics" %}</th>
						<th class="tc3" scope="col">{% trans "Posts" %}</th>
						<th class="tcr" scope="col">{% trans "Last post" %}</th>
					</tr>
				</thead>
				<tbody>
				{% for forum in iter.forums %}
					{% include 'djangobb_forum/forum_row.html' %}
				{% endfor %}
				</tbody>
			</table>
		</div>
	</div>
{% endfor %}
</div>

<div id="brdstats" class="block">
	<h2><span>{% trans "Board information" %}</span></h2>
	<div class="box">
		<div class="inbox">
			<dl class="conr">
				<dt><strong>{% trans "Board statistics" %}</strong></dt>
				<dd>{% trans "Total number of registered users:" %} <strong>{{ users }}</strong></dd>
				<dd>{% trans "Total number of topics:" %} <strong>{{ topics }}</strong></dd>
				<dd>{% trans "Total number of posts:" %} <strong>{{ posts }}</strong></dd>
			</dl>
			<dl class="conl">
				<dt><strong>{% trans "User information" %}</strong></dt>
				<dd>{% trans "Newest registered user:" %} {{ last_user|profile_link }}</dd>
				<dd>{% trans "Registered users online:" %} <strong>{{ online_count }}</strong></dd>
				<dd>{% trans "Guests online:" %} <strong>{{ guest_count }}</strong></dd>
			</dl>
            {% if online_count %}
                <dl id="onlinelist" class= "clearb">
                    <dt><strong>{% trans "Online:" %} </strong></dt>
                    {% for online in users_online %}
                        <dd>{{ online|profile_link }}</dd>
                    {% endfor %}
                </dl>
            {% endif %}
		</div>
	</div>
</div>
{% endblock %}

{% block controls %}
<dl id="searchlinks" class="conl">
	<dt><strong>{% trans "Search links" %}</strong></dt>
	<dd><a href="{% url djangobb:search %}?action=show_24h">{% trans "Show recent posts" %}</a></dd>
	<dd><a href="{% url djangobb:search %}?action=show_unanswered">{% trans "Show unanswered posts" %}</a></dd>
	{% if user.is_authenticated %}
		<dd><a href="{% url djangobb:search %}?action=show_subscriptions">{% trans "Show your subscribed topics" %}</a></dd>
		<dd><a href="{% url djangobb:search %}?action=show_user&amp;user_id={{ request.user.id }}">{% trans "Show your posts" %}</a></dd>
	{% endif %}
</dl>
{% endblock %}

{% block lofi %}
{% if forum_settings.LOFI_SUPPORT %}
    <p class="lofi">
        <a href="{% url djangobb:lofi_index %}">Lo-Fi Version</a>
    </p>
{% endif %}
{% endblock %}
